<template>
  <h3>child</h3>
  <p>{{ count }}</p>
  <button @click="handleClick">更新</button>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "Child",
  props: {
    count: {
      type: Number,
      required: true,
    },
  },
  emits: ["update"],
  setup(props, context) {
    /*
      props数据
      context 一个对象，包含
        attrs
        emit
    */
    console.log(props.count);

    const handleClick = () => {
      context.emit("update");
    };

    return {
      handleClick,
    };
  },
});
</script>
